stepper27 2.2.1
Loading...
Searching...
No Matches
stepper27.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2026 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
27
28#ifndef STEPPER27_H
29#define STEPPER27_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51
57
62
67
72#define STEPPER27_DIR_CW 1
73#define STEPPER27_DIR_CCW 0
74
79#define STEPPER27_PIN_LOW_LEVEL 0
80#define STEPPER27_PIN_HIGH_LEVEL 1
81
86#define STEPPER27_SPEED_VERY_SLOW 0
87#define STEPPER27_SPEED_SLOW 1
88#define STEPPER27_SPEED_MEDIUM 2
89#define STEPPER27_SPEED_FAST 3
90#define STEPPER27_SPEED_VERY_FAST 4
91 // stepper27_set
93
98
103
108#define STEPPER27_MAP_MIKROBUS( cfg, mikrobus ) \
109 cfg.dir = MIKROBUS( mikrobus, MIKROBUS_AN ); \
110 cfg.sleep = MIKROBUS( mikrobus, MIKROBUS_RST ); \
111 cfg.en = MIKROBUS( mikrobus, MIKROBUS_CS ); \
112 cfg.step = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
113 cfg.fault = MIKROBUS( mikrobus, MIKROBUS_INT )
114 // stepper27_map // stepper27
117
122typedef struct
123{
124 digital_out_t dir;
125 digital_out_t sleep;
126 digital_out_t en;
127 digital_out_t step;
128
129 digital_in_t fault;
130
132
137typedef struct
138{
139 pin_name_t dir;
140 pin_name_t sleep;
141 pin_name_t en;
142 pin_name_t step;
143 pin_name_t fault;
144
146
157
163
174
189
199
209
220void stepper27_set_direction ( stepper27_t *ctx, uint8_t dir );
221
231
242void stepper27_set_sleep_pin ( stepper27_t *ctx, uint8_t state );
243
253
264void stepper27_set_step_pin ( stepper27_t *ctx, uint8_t state );
265
275
291void stepper27_drive_motor ( stepper27_t *ctx, uint32_t steps, uint8_t speed );
292
293#ifdef __cplusplus
294}
295#endif
296#endif // STEPPER27_H
297 // stepper27
299
300// ------------------------------------------------------------------------ END
void stepper27_set_direction(stepper27_t *ctx, uint8_t dir)
Stepper 27 set direction function.
err_t stepper27_init(stepper27_t *ctx, stepper27_cfg_t *cfg)
Stepper 27 initialization function.
void stepper27_drive_motor(stepper27_t *ctx, uint32_t steps, uint8_t speed)
Stepper 27 driver motor function.
uint8_t stepper27_get_fault_pin(stepper27_t *ctx)
Stepper 27 get fault pin function.
void stepper27_set_step_pin(stepper27_t *ctx, uint8_t state)
Stepper 27 set step pin function.
void stepper27_reset_device(stepper27_t *ctx)
Stepper 27 reset device function.
void stepper27_cfg_setup(stepper27_cfg_t *cfg)
Stepper 27 configuration object setup function.
void stepper27_switch_direction(stepper27_t *ctx)
Stepper 27 switch direction function.
void stepper27_enable_device(stepper27_t *ctx)
Stepper 27 enable device function.
void stepper27_disable_device(stepper27_t *ctx)
Stepper 27 disable device function.
void stepper27_set_sleep_pin(stepper27_t *ctx, uint8_t state)
Stepper 27 set sleep pin function.
stepper27_return_value_t
Stepper 27 Click return value data.
Definition stepper27.h:152
@ STEPPER27_OK
Definition stepper27.h:153
@ STEPPER27_ERROR
Definition stepper27.h:154
Stepper 27 Click configuration object.
Definition stepper27.h:138
pin_name_t sleep
Definition stepper27.h:140
pin_name_t step
Definition stepper27.h:142
pin_name_t dir
Definition stepper27.h:139
pin_name_t en
Definition stepper27.h:141
pin_name_t fault
Definition stepper27.h:143
Stepper 27 Click context object.
Definition stepper27.h:123
digital_out_t sleep
Definition stepper27.h:125
digital_out_t step
Definition stepper27.h:127
digital_out_t en
Definition stepper27.h:126
digital_in_t fault
Definition stepper27.h:129
digital_out_t dir
Definition stepper27.h:124